
/**
 * @description 新闻列表页面"浏览更多"按钮对应方法
 * @author Huang Yuehong
 * @since 2018-06-27 02:08:45
 */
function loadMoreNews(category){

    var lastnewsId = $('#newsDiv').children("dl:last-child").attr('id').replace("dl","");//最后一条新闻的id
    var loadmorediv = $('#loadmore');// “浏览更多”按钮对象

    // 获取更多新闻的请求地址(每次多加载10条)
    var loadMoreUrl = "/webnews/loadMoreNews/" +category+"/"+lastnewsId;

    // ajax获取新的新闻数据到前台页面
    $.ajax({
        url:loadMoreUrl,
        type:"get",
        dataType:"json",
        success:function(data){
            var map = eval("("+data+")");
            var newsMapList = map['newsMapList'];
            var isShowLoadMore = map['isShowLoadMore'];

            var length = newsMapList.length;
            var dlContent = '';

            // 加载新的新闻数据到div中
            for(var i=0;i< length;i++){

                var content = "<dl id=\""+newsMapList[i]['id']+"\">\n" + "<dt><span><font>"+newsMapList[i]['year']+"</font><font>"+newsMapList[i]['monthDay']+"</font></dt>\n";

                if (newsMapList[i]['picture'] != null && newsMapList[i]['picture'] != ''){
                    content = content + "<dd><img src=\""+ newsMapList[i]['picture'] +"\"/></dd>\n";
                }else{
                    content = content + "<dd><img src=\"/static/images/nophoto.png\"/></dd>\n";
                }
                    content = content + "<dd><a href=\"/webnews/detail/"+newsMapList[i]['id']+"/"+newsMapList[i]['category']+"\" target=\"_blank\" >"+ newsMapList[i]['title'] +"</a></dd>\n" +
                                        "<dd><span>"+ newsMapList[i]['description'] +"</span></dd>\n" +
                                        "<dd><span>"+ newsMapList[i]['interval'] +"</span><span>"+ newsMapList[i]['readtimes'] +"</span><span>"+ newsMapList[i]['keyword'] +"</span></dd>\n" +
                                    "</dl>";
                dlContent = dlContent + content;
            }
            $('#newsDiv').append(dlContent);

            if (isShowLoadMore == 0){
                loadmorediv.hide();//隐藏“浏览更多”按钮
            }

        },
        error:function(XMLHttpRequest,textStatus, errorThrown) {
            // alert(errorThrown);
        }
    });
}